<template>
  <div class="component-business-info">
    <div class="business-info-mod">
      <el-form
        ref="formDataRef"
        label-width="140px"
        :model="formData"
        @submit.prevent
      >
        <div class="ci-wrapper">
          <div class="left-wrap">
            <el-form-item
              :label="$t('product.licenseNumber')+':'"
              required
            >
              <span v-if="formData.creditCode">{{ formData.creditCode }}</span>
              <span
                v-else
                class="noyet-wrap"
              >暂无</span>
            </el-form-item>

            <el-form-item
              :label="$t('product.EnterpriseName')+':'"
              required
            >
              {{ formData.firmName }}
            </el-form-item>

            <el-form-item
              required
              :label="$t('product.EnterpriseResidence')+':'"
            >
              <span v-if="formData.residence"> {{ formData.residence }} </span>
              <span
                v-else
                class="noyet-wrap"
              >暂无</span>
            </el-form-item>

            <el-form-item
              :label="$t('product.legalRepresentative')+':'"
              required
            >
              {{ formData.representative }}
            </el-form-item>

            <el-form-item
              required
              :label="$t('product.registeredCapital')+':'"
            >
              <span v-if="formData.capital"> {{ formData.capital }} </span>
              <span
                v-else
                class="noyet-wrap"
              >暂无</span>
            </el-form-item>

            <el-form-item
              required
              :label="$t('product.establishmentAata')+':'"
            >
              <span v-if="formData.foundTime"> {{ formData.foundTime }} </span>
              <span
                v-else
                class="noyet-wrap"
              >暂无</span>
            </el-form-item>

            <el-form-item
              :label="$t('product.businessTerm')+':'"
            >
              {{ businessTermStr }}
            </el-form-item>

            <el-form-item
              :label="$t('product.businessScope')+':'"
              required
            >
              <span class="business-scope">{{ formData.businessScope }}</span>
            </el-form-item>
          </div>

          <div class="right-wrap">
            <el-form-item
              :label="$t('product.businessLicense')+':'"
              required
            >
              <div class="logo-image-box">
                <el-image
                  v-if="formData.businessLicense"
                  class="logo-image"
                  fit="contain"
                  :src="checkFileUrl(formData.businessLicense)"
                >
                  <template #error>
                    <img
                      class="img-slot"
                      src="@/assets/img/def.png"
                      alt
                    >
                  </template>
                </el-image>
              </div>
            </el-form-item>
          </div>
        </div>
      </el-form>
    </div>
    <div class="footer">
      <div class="foot-box">
        <el-button
          type="primary"
          @click="modifyBasicInfor"
        >
          {{ $t('temp.modify') }}
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { checkFileUrl } from '@/utils/index.js'
const emit = defineEmits(['closeBrowse'])

const businessTermStr = computed(() => {
  const { startTime, endTime } = formData.value
  if (!startTime && !endTime) {
    return $t('order.no')
  }
  return startTime.slice(0, 10) + ' - ' + (endTime ? endTime.slice(0, 10) : $t('product.openEnded'))
})

onMounted(() => {
  queryShopBusinessInfo()
})

const formData = ref({})
/**
 * 修改
 */
const modifyBasicInfor = () => {
  formData.value = {}
  emit('closeBrowse')
}

/**
 * 查询工商信息
 */
const queryShopBusinessInfo = () => {
  http({
    url: http.adornUrl('/admin/shopCompany'),
    method: 'get',
    params: http.adornParams()
  }).then(({ data }) => {
    Object.assign(formData.value, data)
  })
}
</script>

<style lang="scss" scoped>
@use "index";
</style>
